<template>
  <nav aria-label="breadcrumb" class="breadcrumb-nav">
    <div class="container">
      <ol class="breadcrumb">
        <li 
          v-for="(item, index) in items" 
          :key="index" 
          class="breadcrumb-item"
          :class="{ active: item.active }"
        >
          <router-link 
            v-if="!item.active && item.to" 
            :to="item.to"
            class="breadcrumb-link"
          >
            {{ item.text }}
          </router-link>
          <span v-else class="breadcrumb-text">{{ item.text }}</span>
        </li>
      </ol>
    </div>
  </nav>
</template>

<script>
export default {
  name: 'Breadcrumb',
  props: {
    items: {
      type: Array,
      required: true,
      validator: value => {
        return value.every(item => {
          return typeof item.text === 'string' && 
                 (item.active === true || typeof item.to === 'string')
        })
      }
    }
  }
}
</script>

<style scoped >
.breadcrumb-nav {
  background-color: #f5f7fa;
  padding: 1rem 0;
  margin-bottom: 2rem;
  border-bottom: 1px solid #eaeef2;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
  background-color: transparent;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  
  &:not(:first-child)::before {
    content: "/";
    display: inline-block;
    padding: 0 0.5rem;
    color: #c0c4cc;
    font-weight: normal;
  }
  
  &.active {
    color: #606266;
    font-weight: 500;
    
    .breadcrumb-text {
      color: inherit;
    }
  }
}

.breadcrumb-link {
  color: #909399;
  text-decoration: none;
  transition: color 0.2s ease;
  
  &:hover {
    color: #409eff;
    text-decoration: underline;
  }
  
  &:focus {
    outline: none;
    text-decoration: underline;
  }
}

.breadcrumb-text {
  color: inherit;
}

@media (max-width: 768px) {
  .breadcrumb {
    font-size: 0.8rem;
    white-space: nowrap;
    overflow-x: auto;
    padding-bottom: 5px;
  }
  
  .breadcrumb-item {
    flex-shrink: 0;
  }
}
</style>